Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master setobject #30

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Master setobject #30

wants to merge 2 commits into from

Conversation

jguterl
Copy link
Contributor

@jguterl jguterl commented Dec 4, 2021

add setpyobject method in Forthon to be able to alias a Forthon object into a class (ease the dumping/loading of data)

Example with 'face' as Forthon oject:

class test():
def init(self):
for v in face.varlist():
setattr(self.class,v,property(self.getter(v), self.setter(v), face.getvardoc(v)))
@staticmethod
def getter(varname):
def getfaceobj(self):
return face.getpyobject(varname)
return getfaceobj
@staticmethod
def setter(varname):
def setfaceobj(self,vv):
return face.setpyobject(varname,vv)
return setfaceobj

@dpgrote
Copy link
Owner

dpgrote commented Dec 7, 2021

I don't think that this routine is needed. You can do

def setfaceobj(self,vv):
  return setattr(face, varname, vv)

This ends up calling the same routine Forthon_setattro.

@jguterl
Copy link
Contributor Author

jguterl commented Dec 7, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants